package com.zlzxm.shoesmarket.view.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.zlzxm.shoesmarket.R;
import com.zlzxm.shoesmarket.util.ZViewHelp;
import com.zlzxm.shoesmarket.view.adapter.ADCalculatePay;
import com.zlzxm.shoesmarket.view.adapter.ADCalculateSize;
import com.zlzxm.shoesmarket.viewmodel.VMCalculateOwn;

/**
 * CREATE BY zlzxm ON 4/26/21
 * <br>
 *     解读计算器
 */
public class FMCalculateOwn extends BaseFragment{



    VMCalculateOwn vmCalculateOwn;

    RecyclerView rvInfo;

    ADCalculatePay adCalculatePay = new ADCalculatePay();




    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fm_own_calculate,container,false);
    }

    @Override
    protected void initView(@NonNull View view, @NonNull Bundle savedInstanceState) {
        super.initView(view, savedInstanceState);

        View foot =  LayoutInflater.from(getContext()).inflate(R.layout.layout_pay_info_foot,null);

        adCalculatePay.setFooterView(foot);

        rvInfo = ZViewHelp.findById(view,R.id.rvInfo);

        rvInfo.setLayoutManager(new LinearLayoutManager(getContext()));

    }


    @Override
    protected void initViewModel() {
        super.initViewModel();
        vmCalculateOwn = new ViewModelProvider(this).get(VMCalculateOwn.class);
        vmCalculateOwn.getLivePay().observe(this,adCalculatePay::setList);

    }

    @Override
    protected void initData() {
        super.initData();
        rvInfo.setAdapter(adCalculatePay);
        vmCalculateOwn.requestSize();
    }
}
